<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /*
        1. 和函数一样类也有prototype属性
        2. 构造对象本质上继承了类的prototype
        3. 所有类方法都定义在prototype对象上
      */
      class Person {
        constructor() {
          // this = {}
          this.name = "jack";
          // this.__proto__=Person.prototype
          // return this;
        }
        say() {
          console.log("hello");
        }
      }
      Person.prototype.add = function () {};

      const p1 = new Person();
      console.log(p1.say);
      console.log(p1.add);

      // console.log(Person.prototype);
    </script>
  </body>
</html>
